/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.diagram.usecase.helper;

import com.cea.papyrus.core.IPapyrusUIConstants;
import com.cea.papyrus.core.helper.DefaultModelerHelper;
import com.cea.papyrus.core.helper.GraphEdgeHelper;
import com.cea.papyrus.core.helper.NodeHelper;
import com.cea.papyrus.core.utils.Debug;
import com.cea.papyrus.diagram.classdiagram.helper.EdgeAbstractionHelper;
import com.cea.papyrus.diagram.classdiagram.helper.EdgeDependencyHelper;
import com.cea.papyrus.diagram.classdiagram.helper.EdgeGeneralizationHelper;
import com.cea.papyrus.diagram.classdiagram.helper.EdgeGraphLinkHelper;
import com.cea.papyrus.diagram.classdiagram.helper.EdgePackageImportHelper;
import com.cea.papyrus.diagram.classdiagram.helper.EdgeRealizationHelper;
import com.cea.papyrus.diagram.classdiagram.helper.EdgeUsageHelper;
import com.cea.papyrus.diagram.classdiagram.helper.NodeCommentHelper;
import com.cea.papyrus.diagram.classdiagram.helper.NodeConstraintHelper;
import com.cea.papyrus.diagram.classdiagram.helper.NodePackageHelper;
import com.cea.papyrus.diagram.classdiagram.helper.NodePropertyHelper;
import com.cea.papyrus.diagram.composite.helper.NodeClassHelper;

/**
 * Defines management of use case diagrams.
 * 
 * @author Gilles Cannenterre
 * @since 9 oct. 06
 */
public class UseCaseDiagramModelerHelper extends DefaultModelerHelper {

	/**
	 * The EINSTANCE.
	 */
	private static UseCaseDiagramModelerHelper EINSTANCE;

	/**
	 * Gets the instance.
	 * 
	 * @return this instance of ModelResourceManager
	 */
	public static UseCaseDiagramModelerHelper getInstance() {
		if (EINSTANCE == null) {
			EINSTANCE = new UseCaseDiagramModelerHelper();
		}
		return EINSTANCE;
	}

	/**
	 * The channel.
	 */
	private int channel = 203;

	/**
	 * The edge factory.
	 */
	protected GraphEdgeHelper edgeFactory[] = { 
			new EdgeDependencyHelper(), 
			new EdgeAbstractionHelper(),
			new EdgeUsageHelper(),
			new EdgeRealizationHelper(),
			new EdgeGeneralizationHelper(),
			new EdgeAssociationHelper(),
			new EdgeExtendHelper(),
			new EdgePackageImportHelper(),
			new EdgeIncludeHelper(),
			new EdgeGraphLinkHelper()};


	// set of connections
	/**
	 * The edge types.
	 */
	protected Class<?> edgeTypes[] = { 
			org.eclipse.uml2.uml.Dependency.class,
			org.eclipse.uml2.uml.Abstraction.class,
			org.eclipse.uml2.uml.Usage.class,
			org.eclipse.uml2.uml.Realization.class,
			org.eclipse.uml2.uml.Generalization.class,
			org.eclipse.uml2.uml.Association.class,
			org.eclipse.uml2.uml.Extend.class,
			org.eclipse.uml2.uml.PackageImport.class,
			org.eclipse.uml2.uml.Include.class,
			com.cea.papyrus.core.pseudoelement.GraphicalLink.class };

	// Set Uml element that can be created
	/**
	 * The element types.
	 */
	protected Class<?> elementTypes[] = { 
			org.eclipse.uml2.uml.Element.class,
			org.eclipse.uml2.uml.Package.class,
			org.eclipse.uml2.uml.UseCase.class,
			org.eclipse.uml2.uml.Actor.class,
			org.eclipse.uml2.uml.ExtensionPoint.class,
			org.eclipse.uml2.uml.Property.class,
			org.eclipse.uml2.uml.Comment.class,
			org.eclipse.uml2.uml.Constraint.class, 
			org.eclipse.uml2.uml.Class.class};

	// Set of factory that are in the same order that elment types
	/**
	 * The node factory.
	 */
	protected NodeHelper nodeFactory[] = { 
			new NodeHelper(),
			new NodePackageHelper(), 
			new NodeUseCaseHelper(),
			new NodeActorHelper(), 
			new NodeExtensionPointHelper(),
			new NodePropertyHelper(),
			new NodeCommentHelper(),
			new NodeConstraintHelper(),
			new NodeClassHelper() };

	/**
	 * Create the factories for model elements.
	 */
	public UseCaseDiagramModelerHelper() {
		Debug.debug(this, "UseCaseDiagramModelerFactory()", channel);
		for (int i = 0; i < elementTypes.length; i++) {
			creationFactoryMap.put(elementTypes[i], nodeFactory[i]);
		}
		for (int i = 0; i < edgeTypes.length; i++) {
			creationFactoryMap.put(edgeTypes[i], edgeFactory[i]);
		}
	}

	/**
	 * Gets the id.
	 * 
	 * @return the id
	 */
	@Override
	public String getId() {
		return IPapyrusUIConstants.USE_CASE_DIAGRAM;
	}
}